package com.laiketui.app.controller;


import com.laiketui.common.api.ocr.OcrService;
import com.laiketui.core.domain.Result;
import com.laiketui.core.exception.LaiKeAPIException;
import com.laiketui.root.annotation.HttpApiMethod;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ocr识别身份证
 */
@RestController
public class OcrController {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private OcrService ocrService;


    @PostMapping("ocr")
    @HttpApiMethod(urlMapping = "app.ocr.getOcrInfo")
    public Result getOcrInfo(String imgPath, Integer ocrType) throws Exception {
        try{
            //根据识别类型获取
            return Result.success(ocrService.getOcrInfo(ocrType,imgPath));
        }catch (LaiKeAPIException e){
            return Result.error(e.getCode(), e.getMessage(), e.getMethod());
        }
    }
}
